package com.jvyou.thread.test01;

/**
 * @author 橘柚
 * @version 1.0-SNAPSHOT
 * @Date 2024/7/31 15:29
 * @Description
 */
public class WindowThread extends Thread {

    static int ticket = 1000;

    @Override
    public void run() {
        while (true) {
            synchronized (WindowThread.class) {
                if (ticket == 0) {
                    break;
                } else {
                    ticket--;
                    System.out.println(getName() + "卖票，剩余：" + ticket + "张票");
                }
            }
        }
    }
}
